package com.lagou.enums;


/**
 * @Author zhaozuowen
 * @Description
 * @Date 2020/1/1 18:24
 **/

public enum  SqlCommand {

    INSERT,UPDATE,DELETE,SELECT;


    public static SqlCommand convertSqlCommand(String sqlText) throws Exception {

        if(sqlText!=null&&!sqlText.trim().equals("")){
            sqlText=sqlText.trim().toLowerCase();
            if(sqlText.startsWith("insert")){
                return INSERT;
            }else if (sqlText.startsWith("select")){
                return SELECT;
            }else if(sqlText.startsWith("delete")){
                return DELETE;
            }else if(sqlText.startsWith("update")){
                return UPDATE;
            }
        }
        throw new Exception("不合法的sql语句");

    }


}
